package com.ljx.controller;

import com.ljx.autoConfig.LjxService;
import com.ljx.entitl.AliPay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author LJX
 * @Description: TODO
 * @Date: 2022/11/15 9:46
 * @Version 1.0
 */
@RestController

public class HelloController {
	@Autowired
	private AliPay aliPay;

	@GetMapping("/hello")
	public Map<String, Object> demo(){
		Map<String, Object> map = new HashMap<>();
		map.put("ljx",123);
		map.put("ljx1",12);
		return map;
	}
	@Autowired
	private LjxService ljxService;


	/**
	 * springBoot中提供了两种读取配置文件内容的方式
	 * 这是第一种：把读取的配置文件内容封装到实体类中，
	 * @return
	 */
	@RequestMapping("ali")
	public AliPay ali(){
		System.out.println(aliPay);

		ljxService.ljx();

		return aliPay;
	}

	/**
	 * 单个属性读取
	 * @return
	 */
	@Value("${server.port}")
	private Integer port;
	@Value("${ali.app-id}")
	private String appId;
	@Value("${student.name}")
	private String name;
	@RequestMapping("info")
	public String info(){
		return "name:"+name+"port:"+port+"appId"+appId;
	}
}
